package io;
import java.io.*;
import java.util.*;
import utils.*;
public class LoadTestData {

	/**
	 * @param args
	 */
	public static final String testFile = "D:/Users/Nova/Desktop/work/Rec/data/test.txt";
	
	
	public List<UserForTest> allUsers;
	public void loadData(String fileName)	throws IOException{
		BufferedReader bReader = new BufferedReader(new FileReader(fileName));
		allUsers = new ArrayList<UserForTest>();
		String line = bReader.readLine();line = bReader.readLine();
		UserForTest currentUser = null;
		String previousId = "";
		int lineCount = 0;
		while(line!=null && line.length() > 0){
			String[] currentLines = line.split("\\s+");
			
			if(!previousId.equals(currentLines[0]))	{			//add the old user and create a new user
				if(currentUser!=null)
					allUsers.add(currentUser);
				currentUser = new UserForTest(currentLines[0]);
				previousId =  currentLines[0];
			}
			currentUser.addUser(currentLines[1], currentLines[2]);
			
			line = bReader.readLine();
			if(++lineCount%100000 == 0)
				System.out.println(lineCount + "line processed");
		}
		allUsers.add(currentUser);
	}

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		LoadTestData t= new LoadTestData();
		t.loadData(testFile);
		System.out.println(t.allUsers.get(t.allUsers.size()-1).allUserB.get(0).recCount);
	}

}
